package com.itheima.springboot_22_task;

import org.apache.ibatis.logging.stdout.StdOutImpl;

import java.util.Timer;
import java.util.TimerTask;

//这是在java中如何做定时任务
public class TimerTaskApp {
    public static void main(String[] args) {
        Timer timer = new Timer();
        TimerTask task=new TimerTask() {
            @Override
            public void run() { //多线程用到了这个run
                System.out.println("timer task run...");
            }
        };
        timer.schedule(task,0,2000); //task任务,在本程序开始后0秒开始执行,2秒执行一次
    }
}
